<template>
	<el-switch
		v-model="componentVal"
		:active-text="FieldItem?.attrs['active-text']"
		:inactive-text="FieldItem?.attrs['inactive-text']"
		:active-value="FieldItem?.attrs['active-value']"
		:inactive-value="FieldItem?.attrs['inactive-value']"
		:disabled="FieldItem?.attrs['disabled']"
	/>
</template>

<script setup lang="ts">
import { TabFieldType } from '/@/components/Linxyun/custom/DataStructs/commontype';

const props = withDefaults(
	defineProps<{
		modelValue: boolean;
		FieldItem: TabFieldType | null;
	}>(),
	{
		modelValue: false,
		FieldItem: null,
	}
);
const { modelValue, FieldItem } = toRefs(props);

const componentVal = ref(false);
const emit = defineEmits(['update:modelValue']);

componentVal.value = FieldItem.value?.defaultValue;
watch(
	modelValue,
	(newVal) => {
		componentVal.value = newVal ?? false;
	},
	{
		immediate: true,
	}
);
watch(componentVal, (newVal) => {
	emit('update:modelValue', newVal);
});
</script>

<style lang="scss" scoped></style>
